<template>
  <el-table
      :data="tableData"
      style="width: 100%">
    <el-table-column
        label="文件上传日期"
        width="220">
      <template slot-scope="scope">
        <i class="el-icon-time"></i>
        <span style="margin-left: 10px">{{ scope.row.ddate }}</span>
      </template>
    </el-table-column>
    <el-table-column
        label="文件名"
        width="180">
      <template slot-scope="scope">
        <el-popover trigger="hover" placement="top">
          <p>文件名: {{ scope.row.dname }}</p>
          <p>文件大小: {{ scope.row.dsize }}(B)</p>
          <div slot="reference" class="name-wrapper">
            <el-button size="medium" style="border: none" @click="dirshow(scope.row.dname)">{{ scope.row.dname }}</el-button>
          </div>
        </el-popover>
      </template>
    </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
            size="mini"
            @click="handleEdit(scope.row.did, scope.row)">设置共享时长</el-button>
        <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.row.did, scope.row)">取消共享</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  inject:　['reload','downloadFiles','dirdown','dirshow'],
  created() {
    var th=this
    axios({
      url:"/dir/findShare",
      method:"post"
    }).then((resp)=>{
      console.log(resp.data)
      th.tableData=resp.data
    })
  },
  data() {
    return {
      tableData: [{
        ddate: '',
        dname: '',
        dsize: ''
      }]
    }
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(did, row) {
      var th =this;
      axios({
        url:"http://82.156.197.128:8085/dir/offShare",
        method:"POST",
        params:{
          "did":did
        }
      }).then((resp)=>{
        console.log(resp.data)
        th.reload();
      })

    }
  }
}
</script>